Get premium membership and access questions with answers, video lessons as well as revision papers.

Given this class; class planet { int moons; double dist_from_sun; // in miles double diameter; double mass; public: //... double get_ () { return disfrom_sun; } }; Create a function called light() using c++...

      

Given this class;
class planet {
int moons;
double dist_from_sun; // in miles
double diameter;
double mass;
public:
//...
double get_ () { return disfrom_sun; }
};
Create a function called light() using c++ language that takes as an argument an object of type planet and returns the number of secos that it takes light from the sun to reach the planet.(Assume that light travels at 186,000 miles per second and that dist_from_sun is specified in miles.)

  

Answers


Davis
int light (planet p)
{
return p.get_miles () / 186000 ;
Githiari answered the question on May 29, 2018 at 17:42


Next: When an object of a derived class is assigned to another object of the same derived class, is the data associated with the base class...
Previous: Imagine a situation in which two classes, called pr1 and pr2, shown below, share one printer.Further imagine that other parts of your program need to...

View More Computer Science Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions